package com.kreig133.analytic.extractors;

import com.kreig133.analytic.interfaces.DataMiner;
import com.kreig133.spine.abstractmodel.AbstractState;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author C.C.-fag
 */
public class ExperimentExtractor implements DataMiner {

    Map<Double, Double> extractedData;

    public ExperimentExtractor(Map<Double, List<AbstractState>> data) {
        try {
            extractedData = new HashMap<Double, Double>();
            
            List<Double> list = new ArrayList<Double>();
            list.addAll(data.keySet());
            Collections.sort(list);
            
            int lastIndex = data.get(list.get(0)).size() - 1;
            
            for (Double d : list) {
                extractedData.put(d, data.get(d).get(lastIndex).getCoordinate());
            }
        } catch (NullPointerException e) {
            throw new IllegalArgumentException();
        }
    }

    public Map<Double, Double> getProcessedData() throws Exception {
        return  extractedData;
    }
}
